import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
const RoleKey = 'User-Roles'
const UserKey = 'User-Key'

const ExpiresInKey = 'Admin-Expires-In'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getExpiresIn() {
  return Cookies.get(ExpiresInKey) || -1
}

export function setExpiresIn(time) {
  return Cookies.set(ExpiresInKey, time)
}

export function removeExpiresIn() {
  return Cookies.remove(ExpiresInKey)
}

//角色持久化

export function getRoles(){
  return Cookies.get(RoleKey)
}

export function setRoles(roles) {
  return Cookies.set(RoleKey, roles)
}

export function removeRoles() {
  return Cookies.remove(RoleKey)
}

//用户持久化
export function getUser(){
  return Cookies.get(UserKey)
}

export function setUser(user) {
  return Cookies.set(UserKey, user)
}

export function removeUser() {
  return Cookies.remove(UserKey)
}
